﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Intelligent.OTC.Common.UnitOfWork;
using Intelligent.OTC.Domain;
using Intelligent.OTC.Business;
using Intelligent.OTC.Domain.Repositories;
using Intelligent.OTC.Domain.DataModel;
using Intelligent.OTC.WebApi.Core;
using Intelligent.OTC.Common;
using System.Web.OData;
using Intelligent.OTC.Common.Exceptions;
using Intelligent.OTC.Common.Utils;
using Intelligent.OTC.Common.Attr;
using System.Web.OData.Query;

namespace Intelligent.OTC.WebApi.Controllers
{
    [UserAuthorizeFilter(actionSet: "allinfo")]
    public class allinfoController : ApiController
    {
        [HttpGet]
        [PagingQueryable]
        public IQueryable<AllAccountInfo> Get(string invoiceState, string invoiceTrackState, string invoiceNum, string soNum, string poNum, string invoiceMemo)
        {
            ContactindexService service = SpringFactory.GetObjectImpl<ContactindexService>("ContactindexService");

            return service.getAllInvoiceByUser(invoiceState, invoiceTrackState, invoiceNum, soNum, poNum, invoiceMemo);
        }

        [HttpGet]
        public IEnumerable<SendSoaHead> CreateSoa(string ColSoa)
        {
            ContactindexService service = SpringFactory.GetObjectImpl<ContactindexService>("ContactindexService");
            return service.CreateSendMail(ColSoa).AsQueryable();
        }

        [HttpGet]
        public IEnumerable<ContactHistory> GetContactHistory(string CustNumsFCH)
        {
            ContactindexService service = SpringFactory.GetObjectImpl<ContactindexService>("ContactindexService");
            return service.GetContactHistory(CustNumsFCH);
        }

        [HttpGet]
        public HttpResponseMessage ExpoertInvoiceList(string cCode, string cName, string level, string bCode, string bName, string legal,
                                                       string state, string tstate, string iNum, string pNum, string sNum, string memo,string oper)                                              
        {
            ContactindexService service = SpringFactory.GetObjectImpl<ContactindexService>("ContactindexService");
            return service.ExportAccountList(cCode, cName, level, bCode, bName, legal, 
                                              state, tstate, iNum, pNum, sNum, memo,oper);
        }

    }
}